package cn.udinghuo.model.voucher.freight;

import com.fasterxml.jackson.annotation.JsonSetter;

import org.springframework.util.Assert;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Column;
import java.util.Map;
import java.util.HashMap;
import cn.udinghuo.core.domain.entity.BaseAuditTenant;	
import java.math.BigDecimal;	
import cn.udinghuo.model.voucher.freight.FreightComputeLogicEnum;	
import cn.udinghuo.model.voucher.freight.FreightRule;	
import cn.udinghuo.model.voucher.freight.FreightUsableDistrictEnum;	
import cn.udinghuo.model.voucher.freight.FreightWaySettings;	
import cn.udinghuo.model.voucher.freight.FreightWayTypeEnum;	
import java.util.List;	
import cn.udinghuo.core.domain.entity.Comment;
import cn.udinghuo.core.domain.entity.ita.CacheKey;

/**
 * @author xufla
 *	运费方式
 */
@Entity
@Table(name="freightway")
public class FreightWay extends BaseAuditTenant<Long>  {

	private static final long serialVersionUID = -469762049L;
	/**
	* 运费方式freightWayType
	*/
	@Comment(value="运费方式")
	@Column(name="iFreightWayType")
	private Short freightWayType;
	/**
	* 可用的available
	*/
	@Comment(value="可用的")
	@Column(name="bAvailable")
	private Boolean available;
	/**
	* 统一金额设置uniformPrice
	*/
	@Comment(value="统一金额设置")
	@Column(name="fUniformPrice")
	private BigDecimal uniformPrice;
	/**
	* 计算逻辑(数量，重量，单位时使用)computeLogic
	*/
	@Comment(value="计算逻辑(数量，重量，单位时使用)")
	@Column(name="iComputeLogic")
	private Short computeLogic;
	/**
	* 默认配送地区usableDistrict
	*/
	@Comment(value="默认配送地区")
	@Column(name="iUsableDistrict")
	private Short usableDistrict;
	/**
	* 模板idfreightRuleId
	*/
	@Comment(value="模板id")
	@Column(name="iFreightRuleId")
	private Long freightRuleId;
	/**
	* 阶梯设置名称settingName
	*/
	@Comment(value="阶梯设置名称")
	@Transient
	private String settingName;
	@Transient
	private List<FreightWaySettings> freightWaySettings;
	public FreightWayTypeEnum getFreightWayType() {
        if(this.freightWayType == null){
			return null;
		}
		return FreightWayTypeEnum.find(this.freightWayType.intValue());
	}
	@JsonSetter
	public void setFreightWayType(FreightWayTypeEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.freightWayType = value.getValue();
	}
	
	public void setFreightWayType(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(FreightWayTypeEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.freightWayType = value;
	}
	
	public Boolean getAvailable() {
		return this.available;
	}
	
	public void setAvailable(Boolean value) {
		this.available = value;
	}
	
	public BigDecimal getUniformPrice() {
		return this.uniformPrice;
	}
	
	public void setUniformPrice(BigDecimal value) {
		this.uniformPrice = value;
	}
	
	public FreightComputeLogicEnum getComputeLogic() {
        if(this.computeLogic == null){
			return null;
		}
		return FreightComputeLogicEnum.find(this.computeLogic.intValue());
	}
	@JsonSetter
	public void setComputeLogic(FreightComputeLogicEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.computeLogic = value.getValue();
	}
	
	public void setComputeLogic(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(FreightComputeLogicEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.computeLogic = value;
	}
	
	public FreightUsableDistrictEnum getUsableDistrict() {
        if(this.usableDistrict == null){
			return null;
		}
		return FreightUsableDistrictEnum.find(this.usableDistrict.intValue());
	}
	@JsonSetter
	public void setUsableDistrict(FreightUsableDistrictEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.usableDistrict = value.getValue();
	}
	
	public void setUsableDistrict(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(FreightUsableDistrictEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.usableDistrict = value;
	}
	
	public Long getFreightRuleId() {
		return this.freightRuleId;
	}
	
	public void setFreightRuleId(Long value) {
		this.freightRuleId = value;
	}
	
    
	public FreightRule getFreightRule() {
		return (FreightRule) this.getTransient("freightRule");
	}
	
	public void setFreightRule(FreightRule value) {
		this.putTransient("freightRule",value);
	}
	
	public String getSettingName() {
		return this.settingName;
	}
	
	public void setSettingName(String value) {
		this.settingName = value;
	}
	
	public List<FreightWaySettings> getFreightWaySettings() {
		return this.freightWaySettings;
	}
	public void setFreightWaySettings(List<FreightWaySettings> value) {
		this.freightWaySettings = value;
	}
	
}
